<!--版本列表-->
<template>
  <div>
    <avue-crud :data="opinionData"
               :option="opinionOption"
               :page="opinionPage"
               :table-loading="opinionTableLoading"
               @on-load="getOpinionList"
               @search-change="refreshOpinionChange"
               class="menu-min-height">
    </avue-crud>
    <el-dialog
      title=""
      :visible.sync="dialogVisibleReview"
      width="70%"
      :before-close="handleClosesubmit">
      <h2 style="margin-top: -20px;margin-bottom: -10px;">版本详情：</h2>
      <div class="dial">
        <bostech-detail :detail-data="fileDetailData"></bostech-detail>
      </div>
      <div style="text-align: center;">
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisibleReview = false">关 闭</el-button>
          </span>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import getFileDetail from "@/mixins/file/getFileDetail";
  import {getPlaitFileList} from "@/api/make";

  export default {
    name: "opinionList",
    mixins: [getFileDetail()],
    props: {
      achievementId: '',
    },
    created(){
      window.detailOpinion = this.detailOpinion
    },
    data() {
      return {
        opinionPage: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 10 // 每页显示多少条
        },
        opinionData: [],//审批情况列表
        //审批情况表格类型
        opinionOption: {
          page: true,
          menuWidth: 1,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
  indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          keyId: "id",
          column: [
            {
              label: "上传人",
              prop: "createNickname",
              cell: true,
              formatter: function (row, value, label, column) {
                return '<a style="cursor: pointer;" onclick="detailOpinion(\'' + row.makeId + '\')">' + value + '</a>';
              },
            },
            {
              label: "最后上传时间",
              prop: "lastUploadTime",
              cell: true,
            }
          ]
        },
        opinionTableLoading: false,
        // 征求意见列表是否有显示标志
        opinionHaveDataFlag: true,
        // 征求意见详情弹框标志
        dialogVisibleReview: false,
      }
    },
    methods: {
      // 获取征求意见情况 （审批详情相关方法）
      getOpinionList(page, params) {
        this.opinionTableLoading = true;
        getPlaitFileList(Object.assign({
          current: page.currentPage,
          size: page.pageSize,
          achievementId: this.achievementId
        })).then(response => {
          this.opinionData = response.data.data.records;
          this.opinionPage.total = response.data.data.total;
          this.opinionTableLoading = false;
          if (this.opinionData.length > 0) {
            this.opinionHaveDataFlag = true;
          } else {
            this.opinionHaveDataFlag = false;
          }
          this.$emit('haveDataFlag', this.opinionHaveDataFlag)
        })
      },
      refreshOpinionChange() {
        this.getOpinionList(this.opinionPage)
      },
      // 征求意见详情
      detailOpinion(makeId) {
        this.getDetailData_file(makeId, '2');
        this.dialogVisibleReview = true
      }
    }
  };
</script>

